//
//  iTrackGoogleMaps.h
//  iTrack
//
//  Created by Sergei Sevriugin on 6/8/10.
//  Copyright 2010 Bellwood Systems. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "Clients/Maps/GDataMaps.h"
#import "ViewDataManagement.h"

@interface ITGoogleMaps : NSObject {
	
	NSString*								userName;
	NSString*								userPassword;

	NSMutableArray*							maps;
	NSInteger								mapCurrent;
	NSMutableArray*							mapsFeatures;
	BOOL*									mapsFeaturesLoaded;	
	NSInteger								mapsFeatureIndex;
	
	GDataFeedMap*							mapFeed;
	GDataServiceTicket*						mapFeedTicket;
	GDataServiceTicket*						mapEditTicket;

	GDataFeedMapFeature*					featureFeed;
	GDataServiceTicket*						featureFeedTicket;
	GDataServiceTicket*						featureEditTicket;

	UIViewController <ViewDataManagement>*	activeView;
		
	BOOL									saveStart;
	
	NSArray*								messages;
	NSError*								tnxError;
	
	BOOL									isWaiting;
	BOOL									need2wait;
}

@property (retain)				UIViewController*	activeView;
@property (assign)				BOOL				isWaiting;
@property (assign)				BOOL				need2wait;

- (NSString*) userName;
- (NSString*) userPassword;

- (BOOL) getError; 

- (id) initWithUsername:(NSString*)name password:(NSString*)pswd;
- (void)setUserCredentials:(NSString*)name password:(NSString*)pswd;

- (void)fetchMaps;
- (void)addMap:(GDataEntryMap *)map;

- (unsigned)countOfMaps;
- (GDataEntryMap *)getMapAtIndex:(NSUInteger)index;

- (BOOL)featuresOfMapLoaded:(NSInteger)mapid;
- (unsigned)countOfFeaturesOfMap:(NSInteger)mapid;
- (void)fetchFeaturesOfMap:(NSInteger)mapid;
- (GDataEntryMapFeature *)getFeatureOfMap:(NSInteger)mapid AtIndex:(NSUInteger)index;
- (void) deleteFeatureOfMap:(NSInteger)mapid AtIndex:(NSUInteger)index;
- (void) setCurrentMap:(NSInteger)mapid;
- (void) addCurrentMapFeature:(GDataEntryMapFeature *)feature;
- (void) setCurrentMapFeaturesLoaded:(BOOL)loaded;
- (void) saveCurrentMapFeatures;
- (void) updateFeature:(GDataEntryMapFeature *)feature;
- (void) deleteFeature:(GDataEntryMapFeature *)feature;
- (void) updateMap:(NSInteger)mapid;
- (void) deleteMap:(NSInteger)mapid;

@end
